<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>水果店收银系统</title>
    <style>
      body {
        font-family: Arial, sans-serif;
        background-color: #f4f4f4;
        text-align: center;
      }

      .container {
        background-color: white;
        border-radius: 5px;
        padding: 20px;
        margin: 50px auto;
        width: 300px;
        box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
      }

      h1 {
        margin-top: 0;
      }

      input {
        width: 100px;
        padding: 5px;
        margin-bottom: 10px;
      }

      button {
        padding: 10px 20px;
        background-color: #007bff;
        color: white;
        border: none;
        border-radius: 5px;
        cursor: pointer;
      }

      #receipt {
        margin-top: 20px;
      }
    </style>
  </head>

  <body>
    <div id="app">
      <div class="container">
        <h1>欢迎光临_vue开发的收银系统_水果店</h1>
        <p>苹果 10￥ / 斤,折扣<8折></p>
        <label for="weight">请输入你要购买的斤数</label>
        <input type="number" id="weight" v-model.number="count" value="0" />
        <button id="checkout" @click="checkout">结账买单~</button>
        <div id="receipt">
          <p>结账单: 总价: {{ total }}￥ 折后价: {{ discountTotal }}￥ 省了: {{ save }}￥</p>
        </div>
      </div>
    </div>
    <script src="../js/vue.js"></script>
     <script>
        const app = new Vue({
            el:'#app',
            data:{
                count: 0,
                discount:0.8, // 折扣
                total:0,
                discountTotal:0,
                save:0
            },
            methods:{
                checkout(){
                    this.total = this.count * 10,
                    this.discountTotal = this.total * this.discount,
                    this.save = this.total - this.discountTotal
                }
            }
        })
     </script>
  </body>
</html>
